package com.am.user.config;

import com.am.user.properties.AliyunSmsProperties;
import com.am.user.utils.SMSUtil;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AliyunUtilConfiguration {
    //生成一个SMSUtil 的Bean对象，自封装
    @Bean
    @ConditionalOnMissingBean
    public SMSUtil smsUtil(AliyunSmsProperties smsProperties){
        return new SMSUtil(smsProperties.getRegionId(),
                smsProperties.getAccessKeyId(),
                smsProperties.getAccessKeySecret(),
                smsProperties.getSignName(),
                smsProperties.getTemplateCode());
    }
}
